package ar.edu.utn.frsf.cidisi.upcolbpip2pn.generator.petrinet;

public class Place2PN
{
  protected static String nl;
  public static synchronized Place2PN create(String lineSeparator)
  {
    nl = lineSeparator;
    Place2PN result = new Place2PN();
    nl = null;
    return result;
  }

  public final String NL = nl == null ? (System.getProperties().getProperty("line.separator")) : nl;
  protected final String TEXT_1 = NL + NL + "      <place id=\"";
  protected final String TEXT_2 = "\">" + NL + "        <posattr x=\"-126.000000\"" + NL + "                 y=\"90.000000\"/>" + NL + "        <fillattr colour=\"White\"" + NL + "                  pattern=\"\"" + NL + "                  filled=\"false\"/>" + NL + "        <lineattr colour=\"Teal\"" + NL + "                  thick=\"1\"" + NL + "                  type=\"Solid\"/>" + NL + "        <textattr colour=\"Teal\"" + NL + "                  bold=\"false\"/>" + NL + "        <text>";
  protected final String TEXT_3 = "</text>" + NL + "        <ellipse w=\"60.000000\"" + NL + "                 h=\"40.000000\"/>" + NL + "        <token x=\"-10.000000\"" + NL + "               y=\"0.000000\"/>" + NL + "        <marking x=\"0.000000\"" + NL + "                 y=\"0.000000\"" + NL + "                 hidden=\"false\"/>" + NL + "        <type id=\"";
  protected final String TEXT_4 = "\">" + NL + "          <posattr x=\"-90.500000\"" + NL + "                   y=\"66.000000\"/>" + NL + "          <fillattr colour=\"White\"" + NL + "                    pattern=\"Solid\"" + NL + "                    filled=\"false\"/>" + NL + "          <lineattr colour=\"Teal\"" + NL + "                    thick=\"0\"" + NL + "                    type=\"Solid\"/>" + NL + "          <textattr colour=\"Teal\"" + NL + "                    bold=\"false\"/>" + NL + "          <text tool=\"CPN Tools\"" + NL + "                version=\"2.2.0\">";
  protected final String TEXT_5 = "</text>" + NL + "        </type>" + NL + "        <initmark id=\"";
  protected final String TEXT_6 = "\">" + NL + "          <posattr x=\"-69.000000\"" + NL + "                   y=\"113.000000\"/>" + NL + "          <fillattr colour=\"White\"" + NL + "                    pattern=\"Solid\"" + NL + "                    filled=\"false\"/>" + NL + "          <lineattr colour=\"Black\"" + NL + "                    thick=\"0\"" + NL + "                    type=\"Solid\"/>" + NL + "          <textattr colour=\"Black\"" + NL + "                    bold=\"false\"/>";
  protected final String TEXT_7 = NL + "          <text tool=\"CPN Tools\"" + NL + "                version=\"2.2.0\">1</text>";
  protected final String TEXT_8 = NL + "          <text tool=\"CPN Tools\"" + NL + "                version=\"2.2.0\"/>";
  protected final String TEXT_9 = "         " + NL + "        </initmark>";
  protected final String TEXT_10 = NL + "        <port id=\"";
  protected final String TEXT_11 = "\"" + NL + "              type=\"";
  protected final String TEXT_12 = "\">" + NL + "          <posattr x=\"-78.000000\"" + NL + "                   y=\"44.000000\"/>" + NL + "          <fillattr colour=\"White\"" + NL + "                    pattern=\"Solid\"" + NL + "                    filled=\"false\"/>" + NL + "          <lineattr colour=\"Black\"" + NL + "                    thick=\"0\"" + NL + "                    type=\"Solid\"/>" + NL + "          <textattr colour=\"Black\"" + NL + "                    bold=\"false\"/>" + NL + "        </port>";
  protected final String TEXT_13 = NL + "        <fusioninfo id=\"";
  protected final String TEXT_14 = "\"" + NL + "                    name=\"termination\">" + NL + "          <posattr x=\"115.000000\"" + NL + "                   y=\"-79.000000\"/>" + NL + "          <fillattr colour=\"White\"" + NL + "                    pattern=\"Solid\"" + NL + "                    filled=\"false\"/>" + NL + "          <lineattr colour=\"Black\"" + NL + "                    thick=\"0\"" + NL + "                    type=\"Solid\"/>" + NL + "          <textattr colour=\"Black\"" + NL + "                    bold=\"false\"/>" + NL + "        </fusioninfo>";
  protected final String TEXT_15 = NL + "        " + NL + "      </place>";
  protected final String TEXT_16 = NL;

  public String generate(Object argument)
  {
    final StringBuffer stringBuffer = new StringBuffer();
     Place place = (Place) argument; 
    stringBuffer.append(TEXT_1);
    stringBuffer.append( place.getId());
    stringBuffer.append(TEXT_2);
    stringBuffer.append( place.getText());
    stringBuffer.append(TEXT_3);
    stringBuffer.append( place.getTypeId());
    stringBuffer.append(TEXT_4);
    stringBuffer.append( place.getType());
    stringBuffer.append(TEXT_5);
    stringBuffer.append( place.getMarkId());
    stringBuffer.append(TEXT_6);
    if (place.isInitialMarking()){
    stringBuffer.append(TEXT_7);
    }else{
    stringBuffer.append(TEXT_8);
    }
    stringBuffer.append(TEXT_9);
    if (place.getPortId()!=null){
    stringBuffer.append(TEXT_10);
    stringBuffer.append( place.getPortId());
    stringBuffer.append(TEXT_11);
    stringBuffer.append( place.getPortType());
    stringBuffer.append(TEXT_12);
    }
    if (place.getFusionId()!=null){
    stringBuffer.append(TEXT_13);
    stringBuffer.append( place.getFusionId());
    stringBuffer.append(TEXT_14);
    }
    stringBuffer.append(TEXT_15);
    stringBuffer.append(TEXT_16);
    return stringBuffer.toString();
  }
}
